//
//  MineListTwoDetailViewController.m
//  Mahjong
//
//  Created by KING on 16/9/3.
//  Copyright © 2016年 swift. All rights reserved.
//

#import "MineListTwoDetailViewController.h"
#import "Header.h"
#import "MineListNumberTableViewCell.h"
#import "MineListAdressTableViewCell.h"
@interface MineListTwoDetailViewController ()
<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) UITableView *myTableView;

@end

@implementation MineListTwoDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, SCREENH_HEIGHT-80) style:UITableViewStylePlain];
    [self.view addSubview:self.myTableView];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self.myTableView registerNib:[UINib  nibWithNibName:@"MineListNumberTableViewCell" bundle:nil] forCellReuseIdentifier:@"numbercell"];
    self.myTableView.backgroundColor = [UIColor colorWithRed:239/255.0 green:239/255.0 blue:239/255.0 alpha:1];

    [self.myTableView registerNib:[UINib nibWithNibName:@"MineListAdressTableViewCell" bundle:nil] forCellReuseIdentifier:@"adresscell"];
    [self.myTableView registerClass:[UITableViewCell class] forCellReuseIdentifier:@"cell"];
    [self createButton];
    self.navigationItem.title = @"订单详情";
    
    UIBarButtonItem *backItem = [[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"nav_but_back"] style:(UIBarButtonItemStyleDone) target:self action:@selector(backAction)];
    backItem.tintColor = [UIColor grayColor];
    self.navigationItem.leftBarButtonItem = backItem;
    
}

- (void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
-(void)createButton{
    UIView *backView = [[UIView alloc] initWithFrame:CGRectMake(0, SCREENH_HEIGHT-105, SCREEN_WIDTH, 45)];
    backView.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:backView];
    
   
    
    UIButton *okButton = [UIButton buttonWithType:UIButtonTypeCustom];
    okButton.frame = CGRectMake(SCREEN_WIDTH- 100, 5, 90, 35);
    okButton.backgroundColor = [UIColor orangeColor];
    [okButton setTitle:@"取消订单" forState:UIControlStateNormal];
    [backView addSubview:okButton];
    okButton.layer.cornerRadius = 5;

    
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 5;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 2;
    }
    if (section == 2) {
        return 4;
    }
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        
        if (indexPath.row == 0) {
            MineListNumberTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"numbercell"];
            return cell;
        }
        else {
            MineListAdressTableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"adresscell"];
            return cell;
        }
        
    }
    
    if (indexPath.section == 1) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        cell.imageView.image = [UIImage imageNamed:@"icon_area@2x"];
        cell.textLabel.text = @"施工面积";
        
        UILabel *lab = [[UILabel alloc] initWithFrame:CGRectMake(SCREEN_WIDTH-100, 0, 100, 22)];
        lab.text = @"234平米";
        lab.textAlignment = NSTextAlignmentRight;
        [cell addSubview:lab];
        return cell;
    }
    if (indexPath.section == 2) {
        if (indexPath.row == 0) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"麻将桌";
            return cell;
        }
        if (indexPath.row == 1) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"转盘";
            return cell;
        } if (indexPath.row == 2) {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"椅子";
            return cell;
        }  else {
            UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
            cell.imageView.image = [UIImage imageNamed:@"abc.jpg"];
            cell.textLabel.text = @"水晶牌";
            return cell;
        }

        
    }
    if (indexPath.section == 3) {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        cell.textLabel.text  = @"运费¥20(送货)";
        return cell;
    }
    else {
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cell"];
        cell.textLabel.text  = @"顺丰门第已接单";
        UIImageView *imge = [[UIImageView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH - 40, 5, 25, 22)];
        imge.image = [UIImage imageNamed:@"me_but_tel@2x"];
        [cell addSubview:imge];
        return cell;
        
    }
    
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return 35;
    }
    return 10;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        if (indexPath.row == 1) {
            return 80;
        }
    }
    return 40;
}
-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section{
    if (section == 2) {
        return @"定制无聊";
    }
    return nil;
}


- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
